//
//  SongsTableViewCell.swift
//  ShareMusic
//
//  Created by 胡岩 on 16/5/4.
//  Copyright © 2016年 胡岩. All rights reserved.
//

import UIKit

class SongsTableViewCell: UITableViewCell {

    var singer:UILabel?
    var song:UILabel?
    var option:UIButton?
    var line:UIView?
    private var mo:songModel?
    var model:songModel {
        get {
            return mo!
        }
        set {
            mo = newValue
            singer?.text = (mo?.singer_name)!
            song?.text = (mo?.song_name)!
        }
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        singer = UILabel.init()
        song = UILabel.init()
        option = UIButton.init(type: UIButtonType.Custom)
        line = UIView.init()
        
        self.contentView.addSubview(singer!)
        self.contentView.addSubview(song!)
//        self.contentView.addSubview(option!)
        self.contentView.addSubview(line!)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        line?.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 0.5)
        line?.backgroundColor = UIColor.backColor()
        song?.frame = CGRectMake(10, 8, self.contentView.frame.size.width - 20, 15)
        song?.font = UIFont.systemFontOfSize(17)
        
        singer?.frame = CGRectMake(10, 30, self.contentView.frame.size.width - 20, 15)
        singer?.font = UIFont.systemFontOfSize(13)
        singer?.textColor = UIColor.greyTextColor()
        
        option?.frame = CGRectMake(self.contentView.frame.size.width - self.contentView.frame.size.height, 0, self.contentView.frame.size.height, self.contentView.frame.size.height)
        option?.addTarget(self, action: #selector(self.optionMore(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        option?.setImage(UIImage.init(named: "向下"), forState: UIControlState.Normal)
    }
    
    func optionMore(button:UIButton) {
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
